package com.ftg.learn.day08;

/**
 * 可变字符序列
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/7/24 下午1:35
 */
public class StringBuilder01 {

    public static void main(String[] args) {
        StringBuilder stringBuilder = new StringBuilder();
        //回文数 : 123 12321  77 6
        int a = 1221;
//        append 未尾添加
        String astr = stringBuilder.append(a).toString();

        //reverse 反转
        String newStr = stringBuilder.reverse().toString();

        System.out.println(astr.equals(newStr));

        //insert 插入
        StringBuilder builder1 = new StringBuilder();
        System.out.println(builder1.append("bcd").insert(0, 1).insert(2,2).append("3") );

        //所有String里面的方法 在 StringBuilder里面全部都 有

        //setLength设置长茺
//        builder1.setLength(2);

//        delete 范围删除

        builder1.delete(0,4);

//        setCharAt 修改下标对应的char
        builder1.setCharAt(1,'f');

        StringBuilder b1 = new StringBuilder("a");
        StringBuilder b2 = new StringBuilder("b");

        //-1 比较
//        System.out.println(b1.compareTo(b2));

        System.out.println(builder1);



    }

}
